<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D旋转轮播图</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #000;
            perspective: 1000px;
        }

        .carousel-container {
            position: relative;
            width: 600px;
            height: 400px;
            transform-style: preserve-3d;
        }

        .carousel-wrapper {
            position: relative;
            width: 100%;
            height: 100%;
            transform-style: preserve-3d;
            transition: transform 0.6s ease;
        }

        .carousel-item {
            position: absolute;
            width: 200px;
            height: 200px;
            left: 50%;
            top: 50%;
            transform-origin: center center;
            transform-style: preserve-3d;
            transition: all 0.6s ease;
            cursor: pointer;
            backface-visibility: hidden;
        }

        .carousel-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
        }

        .carousel-item.sel {
            transform: translate(-50%, -50%) translateZ(200px) scale(1.2);
            z-index: 1;
        }

        .carousel-item:not(.sel) {
            transform: translate(-50%, -50%) rotateY(calc(var(--i) * 72deg)) translateZ(300px);
            filter: brightness(0.7);
        }

        .control-button {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            width: 50px;
            height: 50px;
            background: rgba(255, 255, 255, 0.2);
            border: none;
            border-radius: 50%;
            color: white;
            font-size: 24px;
            cursor: pointer;
            transition: background-color 0.3s;
            z-index: 2;
        }

        .control-button:hover {
            background: rgba(255, 255, 255, 0.4);
        }

        .left {
            left: 20px;
        }

        .right {
            right: 20px;
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
    <div class="carousel-container">
        <div class="rotas">
            <div class="carousel-item sel" style="--i: 0">
                <img src="../img/1 (1).png" alt="图片1">
            </div>
            <div class="carousel-item" style="--i: 1">
                <img src="../img/1 (2).png" alt="图片2">
            </div>
            <div class="carousel-item" style="--i: 2">
                <img src="../img/1 (3).png" alt="图片3">
            </div>
            <div class="carousel-item" style="--i: 3">
                <img src="../img/1 (4).png" alt="图片4">
            </div>
            <div class="carousel-item" style="--i: 4">
                <img src="../img/1 (5).png" alt="图片5">
            </div>
        </div>
        <button class="control-button left">←</button>
        <button class="control-button right">→</button>
    </div>

    <script>
        $(document).ready(function() {
            let rotas = $('.rotas');
            let rotasPro = $('.carousel-item');
            let rightBtn = $('.right');
            let leftBtn = $('.left');
            let deg = 0;
            let degImg = 0;

            const changeRotas = (obj, n) => {
                deg = n > 0 ? deg + 1 : deg - 1;
                obj.css('transform', `rotateY(${deg * 72}deg)`);
            }

            const changeImgs = (n) => {
                if (n > 0) {
                    degImg = ++degImg >= 5 ? 0 : degImg;
                } else {
                    degImg = --degImg < 0 ? 4 : degImg;
                }
                rotasPro.removeClass('sel');
                $(rotasPro[degImg]).addClass('sel');
            }

            rightBtn.click(function() {
                changeRotas(rotas, 1);
                changeImgs(1);
            });

            leftBtn.click(function() {
                changeRotas(rotas, -1);
                changeImgs(-1);
            });

            let autoRota = setInterval(function() {
                changeRotas(rotas, -1);
                changeImgs(-1);
            }, 4000);

            $('.carousel-container').hover(
                function() {
                    clearInterval(autoRota);
                },
                function() {
                    autoRota = setInterval(function() {
                        changeRotas(rotas, -1);
                        changeImgs(-1);
                    }, 4000);
                }
            );
        });
    </script>
</body>
</html>